home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / bgui11b.lha / docs / baseclass.doc next >
Encoding:
Text File  |  1994-10-24  |  16.3 KB  |  407 lines

  1.  
  2.            $RCSfile: baseclass.doc,v $
  3.         Description: Baseclass documentation.
  4.           Copyright: (C) Copyright 1994 Jaba Development.
  5.                      (C) Copyright 1994 Jan van den Baard.
  6.                      All Rights Reserved.
  7.  
  8.             $Author: jaba $
  9.           $Revision: 1.7 $
  10.               $Date: 1994/10/02 14:18:07 $
  11. ------------------------------------------------------------------------------
  12.  
  13. TABLE OF CONTENTS
  14.  
  15. baseclass/--background--
  16. baseclass/Methods
  17. baseclass/Attributes
  18.  
  19. baseclass/--background--                              baseclass/--background--
  20.  
  21.     NAME
  22.         Class:          baseclass
  23.         Superclass:     GADGETCLASS
  24.         Include File:   <libraries/bgui.h>
  25.  
  26.     FUNCTION
  27.         This is the most important gadget class in BGUI.  It is the superclass
  28.         of almost all the other gadget classes at one point  or the other.  It
  29.         will take care of the following things for it's subclasses:
  30.  
  31.         o Notification
  32.         o Frames
  33.         o Labels
  34.         o Online-help.
  35.  
  36.         If you plan on writing a class for BGUI then always sub-class in  from
  37.         this class. That way you automatically  inherrit the  above  mentioned
  38.         features.
  39.  
  40. baseclass/Methods                                            baseclass/Methods
  41.  
  42.     NOTE
  43.         The methods described here are also valid  for  the other  BGUI gadget
  44.         classes subclassed from this class unless documented otherwise.
  45.  
  46.     NEW METHODS
  47.         BASE_ADDMAP -- This method must be used to add a target  object to  an
  48.                 object it's maplist notification  list.   Maplist notification
  49.                 is  simular  to  the  notification  performed  by  the  system
  50.                 "icclass" and ICA_TARGET notification.  This  method  uses the
  51.                 following custom message structure:
  52.  
  53.                 struct bmAddMap {
  54.                         ULONG           MethodID;    /* BASE_ADDMAP */
  55.                         Object         *bam_Object;  /* Target object */
  56.                         struct TagItem *bam_MapList;
  57.                 };
  58.  
  59.                 bam_MapList --  This   can   point  to  an  array  of  TagItem
  60.                 structures which contains a  set of  attributes  to map.  This
  61.                 may also be NULL in which case no mapping is done.
  62.  
  63.                 Returns TRUE uppon success, FALSE uppon failure.
  64.  
  65.         BASE_ADDCONDITIONAL -- This method must be used to add a target object
  66.                 to an object it's conditional notification list.   Conditional
  67.                 notification is a simple "if attr a == b then set attr c to d"
  68.                 style of notification. Example:
  69.  
  70.                 Object          *cycle, *string;
  71.  
  72.                 DoMethod( cycle, BASE_ADDCONDITIONAL, string,
  73.                         CYC_Active,  0,
  74.                         GA_Disabled, FALSE,
  75.                         GA_Disabled, TRUE );
  76.  
  77.                 This  will  enable  the  string  gadget  when  the  CYC_Active
  78.                 attribute  of  the  cycle  gadget  is 0.   If  the  CYC_Active
  79.                 attribute is not 0 the string gadget is disabled.
  80.  
  81.                 This method uses the following custom message structure:
  82.  
  83.                 struct bmAddConditional {
  84.                         ULONG           MethodID;   /* BASE_ADDCONDITIONAL */
  85.                         Object         *bac_Object; /* Target object. */
  86.                         struct TagItem  bac_Condition;
  87.                         struct TagItem  bac_TRUE;
  88.                         struct TagItem  bac_FALSE;
  89.                 };
  90.  
  91.                 bac_Condition -- This attribute pair represents  the condition
  92.                         which has to be met.
  93.  
  94.                 bac_TRUE -- This attribute pair is set to the target object if
  95.                         the condition is TRUE (I.E. met).
  96.  
  97.                 bac_FALSE -- This attribute pair is set to  the target  object
  98.                         if the condition is FALSE (I.E. not met).
  99.  
  100.                 Returns TRUE uppon success, FALSE uppon failure.
  101.  
  102.         BASE_ADDMETHOD -- This method must be used to  add a target  object to
  103.                 an object it's method notification list.   Method notification
  104.                 allows  you  to  send a  complete  method to a  target  when a
  105.                 notification  event occures.   This method uses  the following
  106.                 custom message structure:
  107.  
  108.                 struct bmAddMethod {
  109.                         ULONG           MethodID;   /* BASE_ADDMETHOD */
  110.                         Object         *bam_Object; /* Target object. */
  111.                         ULONG           bam_Flags;
  112.                         ULONG           bam_Size;
  113.                         ULONG           bam_MethodID;
  114.                 };
  115.  
  116.                 bam_Flags -- This may contain any of the following flags:
  117.  
  118.                         BAMF_NO_GINFO -- Normally a pointer  to  a  GadgetInfo
  119.                                 structure is inserted in  the method  to send.
  120.                                 When this flag is set this  will not  be done.
  121.                                 Please note that  when a GadgetInfo  is placed
  122.                                 it is done as follows:
  123.  
  124.                                 OM_NEW, OM_SET, OM_UPDATE, OM_NOTIFY -- If the
  125.                                         method to  send  is  any of  these the
  126.                                         GadgetInfo  is  placed  in  the  third
  127.                                         long word of  the  method.  All  other
  128.                                         methods will get the GadgetInfo in the
  129.                                         second long word.  This  behaviour  is
  130.                                         the same as with DoGadgetMethodA().
  131.  
  132.                         BAMF_NO_INTERIM -- When set  the  method  will not  be
  133.                                 send on interim notification events.
  134.  
  135.                 bam_Size -- This field must contain the number  of  long-words
  136.                         _including_ the method ID of the method to send.  This
  137.                         information is needed because a copy of  the method to
  138.                         send is made in an internal buffer.
  139.  
  140.                 bam_MethodID -- This must be  the  ID of the  method to  send.
  141.                         This  field  can  be  followed  by the method specific
  142.                         data.
  143.  
  144.                 Please  note   that   most  notification  will  occure on  the
  145.                 input.device it's task. This means that the called method must
  146.                 not  take  to  long  to  return  and  generally  should not do
  147.                 anything a normal input handler should not do.
  148.  
  149.                 Returns TRUE uppon success, FALSE uppon failure.
  150.  
  151.         BASE_REMMAP,  BASE_REMCONDITIONAL,   BASE_REMMETHOD,   BASE_REMHOOK --
  152.                 These methods must be used to remove a target object/hook from
  153.                 any of the notification lists.  This method uses the following
  154.                 message structure:
  155.  
  156.                 struct bmRemove {
  157.                         ULONG           MethodID;   /* Any of the above. */
  158.                         Object         *bar_Object; /* Object to remove. */
  159.                 };
  160.  
  161.                 Return code not defined.
  162.  
  163.         BASE_SETLOOP,     BASE_CLEARLOOP,     BASE_CHECKLOOP,    BASE_LEFTEXT,
  164.         BASE_SHOWHELP -- These methods are private and  should not  be of  any
  165.                 use to you.
  166.  
  167.         BASE_ADDHOOK -- This method must be used to add a  hook routine to the
  168.                 object it's hook-notification list.   Hook notification allows
  169.                 you to add a routine via  a Hook  to the  notification  of the
  170.                 object. In other words, the hook will be  called  whenever the
  171.                 object  sends  out  a  notification.   This  method  uses  the
  172.                 following custom message structure:
  173.  
  174.                 struct bmAddHook {
  175.                         ULONG           MethodID; /* BASE_ADDHOOK */
  176.                         struct Hook    *bah_Hook;
  177.                 };
  178.  
  179.                 bah_Hook -- A pointer to the Hook structure.
  180.  
  181.                 Your hook routine will be called as follows:
  182.  
  183.                 rc = hookFunc( hook, obj, update );
  184.                 D0             A0    A2   A1
  185.  
  186.                 hook -- This will point to the Hook structure.
  187.  
  188.                 obj -- This  is  a  pointer  to  the  object  that  caused the
  189.                         notification.
  190.  
  191.                 update -- This is a pointer to a opUpdate structure from which
  192.                         you can extract data like the  visual  environment and
  193.                         notified attribute changes.
  194.  
  195.                 Your hook routine must return non-zero  when the  notification
  196.                 caused a change of some sort and zero if not.
  197.  
  198.                 Returns TRUE uppon success and FALSE uppon failure.
  199.  
  200.     SEE ALSO
  201.         intuition.library/DoGadgetMethodA(), icclass, ICA_TARGET,
  202.         utility/hooks.h
  203.  
  204.     CHANGED METHODS
  205.         OM_UPDATE -- This method fixes a bug in the system  GADGETCLASS.  Even
  206.                 though the documentation states that the GA_ID  attribute of a
  207.                 gadget object cannot  be  changed  by a  OM_UPDATE  message it
  208.                 still does.  As this behaviour  is not  correct  the baseclass
  209.                 intercepts the GA_ID  attribute  before passing  it on to  the
  210.                 GADGETCLASS.  This  way  GA_ID  will  not  be  changable  by a
  211.                 OM_UPDATE call.
  212.  
  213.         OM_NOTIFY -- This method will first  execute all maplist, conditional,
  214.                 method and hook notification.  When that  is  done the  method
  215.                 is passed onto  GADGETCLASS  for any  ICA_TARGET's that  might
  216.                 still exist.
  217.  
  218.         GM_RENDER -- If this message requests a  complete  re-rendering  (I.E.
  219.                 GREDRAW_REDRAW) this method will  render the  frame  and label
  220.                 when available. On any other request it will simply re-compute
  221.                 the gadget hitbox bounds.  When this method returns a non-NULL
  222.                 value you are also allowed to render.   If this method returns
  223.                 NULL then you may not render.
  224.  
  225.                 Your   class  _must_  also  follow  the  same  rules.  If  the
  226.                 superclass  of  your  class returns NULL you do not render and
  227.                 also  return  NULL.  If the superclass of your class returns a
  228.                 non-NULL  value  you  should render and also return a non-NULL
  229.                 value.
  230.  
  231.                 Your class must  use  the gpr_RPort field for _all_ rendering.
  232.                 This usually points to a buffer rastport in  which  you render
  233.                 without it showing on screen.  This  also  means  that if your
  234.                 class uses OM_SET on another  object  you  must do  so without
  235.                 passing the gpr_GInfo field and re-render that object later in
  236.                 the RastPort pointed to by the gpr_RPort field.
  237.  
  238.                 RastPort-Clipping is not allowed for BGUI objects.  The reason
  239.                 for this limitation is that all rendering occures in  a buffer
  240.                 rastport  without  a  layer  attached  to  it.   If your class
  241.                 absolutely needs clipping you must  use the  WINDOW_NoBufferRP
  242.                 or PAGE_NoBufferRP on  the window  object  or page  object  in
  243.                 which the object is located.
  244.  
  245.         GM_HITTEST -- This method will return  GMR_GADGETHIT  when  the gadget
  246.                 was clicked inside it's hitbox bounds.
  247.  
  248.     SEE ALSO
  249.         <intuition/gadgetclass.h>
  250.  
  251. baseclass/Attributes                                      baseclass/Attributes
  252.  
  253.     NOTE
  254.         The attributes described here are also valid for the other BGUI gadget
  255.         classes subclassed from this class unless documented otherwise.
  256.  
  257.     NAME
  258.         BT_HelpFile -- ( STRPTR )
  259.  
  260.     FUNCTION
  261.         Set the name of the file to be displayed when a  help-request  for the
  262.         object arives. Please note that the full path-name must be given.
  263.  
  264.         Default is NULL. Applicability is (IS).
  265.  
  266.     SEE ALSO
  267.         BT_HelpNode, BT_HelpLine
  268.  
  269.     NAME
  270.         BT_HelpNode -- ( STRPTR )
  271.  
  272.     FUNCTION
  273.         Set the name of the node which is diplayed in the help window.
  274.  
  275.         Default is NULL. Applicability is (IS).
  276.  
  277.     SEE ALSO
  278.         BT_HelpFile, BT_HelpLine
  279.  
  280.     NAME
  281.         BT_HelpLine - ( ULONG )
  282.  
  283.     FUNCTION
  284.         Set the line number  from  which the  file is  displayed.  This may be
  285.         useful if the help-file is not an AmigaGuide file.
  286.  
  287.         Default is 0. Applicability is (IS).
  288.  
  289.     SEE ALSO
  290.         BT_HelpFile, BT_HelpNode
  291.  
  292.     NAME
  293.         BT_HitBox - ( struct IBox * )
  294.  
  295.     FUNCTION
  296.         Get the hitbox bounds of the gadget object. This attribute is normally
  297.         only usefull for class writers.  Please  note that the contents of the
  298.         returned IBox  structure  is only  valid  _after_  you let  this class
  299.         render itself. For example suppose the  following  code is  your class
  300.         dispatcher:
  301.  
  302.         __saveds __asm ULONG
  303.         dispatcher ( __a0 Class *cl, __A2 Object *obj, __A1 Msg msg )
  304.         {
  305.                 struct IBox             *domain;
  306.  
  307.                 switch ( msg->MethodID ) {
  308.  
  309.                         ...
  310.  
  311.                         case    GM_RENDER:
  312.                                 /*
  313.                                 **      First let the superclass render.
  314.                                 **/
  315.                                 if ( ! DoSuperMethodA( cl, obj, msg ))
  316.                                         return( 0L );
  317.                                 /*
  318.                                 **      Now you can obtain the object
  319.                                 **      it's hitbox bounds.
  320.                                 **/
  321.                                 DoSuperMethod( cl, obj, OM_GET,
  322.                                                BT_HitBox, &domain );
  323.  
  324.                                 ...
  325.  
  326.                                 break;
  327.                 }
  328.         }
  329.  
  330.         Please note that the pointer returned is READ-ONLY.  If  you  need  to
  331.         adjust it's contents you should make a private copy of the data.
  332.  
  333.         Applicability is (G).
  334.  
  335.     NAME
  336.         BT_LabelObject, BT_FrameObject -- ( Object * )
  337.  
  338.     FUNCTION
  339.         Set or get the frame/label object to use. Normally only  class writers
  340.         use these attributes.  You can use  them to  obtain a  pointer  to the
  341.         label/frame object or to erase/change the label/frame object.  If, for
  342.         example, your class uses it's own custom rendering you can  dispose of
  343.         the baseclass frame by setting it to NULL like this:
  344.  
  345.         SetAttrs( object, FRM_FrameObject, NULL, TAG_END );
  346.  
  347.         Default  is  the  frame/label  build from the attributes passed to the
  348.         object at create time. Applicability is (SG).
  349.  
  350.     SEE ALSO
  351.         intuition.library/SetAttrs()
  352.  
  353.     NAME
  354.         BT_TextAttr -- ( struct TextAttr * )
  355.  
  356.     FUNCTION
  357.         Set the font which will be used by the frame and  label of  the class.
  358.         Class writers might  want  to  intercept  and  copy  this data  before
  359.         passing it onto the superclass.
  360.  
  361.         Default is NULL. Applicability is (S).
  362.  
  363.     NAME
  364.         BT_NoRecessed -- ( BOOL )
  365.  
  366.     FUNCTION
  367.         To tell the baseclass not to recess the frame when the  gadget  object
  368.         is selected. The checkboxclass uses this attribute.
  369.  
  370.     NAME
  371.         BT_LabelClick -- ( BOOL )
  372.  
  373.     FUNCTION
  374.         To  tell  the  baseclass  to  also consider clicking inside the gadget
  375.         label as a hit.
  376.  
  377.         Default is FALSE. Applicability is (I).
  378.  
  379.     SEE ALSO
  380.         Methods/GM_GADGETHIT
  381.  
  382.     NOTE
  383.         All frameclass and labelclass attributes are also valid  when creating
  384.         a baseclass object.
  385.  
  386.     NAME
  387.         BT_HelpText -- ( STRPTR)
  388.  
  389.     FUNCTION
  390.         To setup  a  text  which  will be displayed if the help-key is pressed
  391.         while the  mouse  pointer  is located above the object. This attribute
  392.         should be  used  to  attach small on-line help to the object. The text
  393.         you specify will be shown in a small BGUI_RequestA() type of requester
  394.         so you  must  make  sure  that  everything  fit's  nicely on a 600x200
  395.         screen.
  396.  
  397.         The specified text may contain any of the infoclass command sequences.
  398.  
  399.         This attribute overides the BT_HelpFile,  BT_HelpNode and  BT_HelpLine
  400.         attributes.
  401.  
  402.         Default is NULL. Applicability (IS).
  403.  
  404.     SEE ALSO
  405.         BT_HelpFile, BT_HelpNode, BT_HelpLine, infoclass/INFO_TextFormat,
  406.         bgui.library/BGUI_RequestA()
  407.